﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member
{
    public partial class shoppic : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind0();
            }
        }
        private void bind0()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");
            Image1.ImageUrl = s.cbpath2.ToString();
            Image2.ImageUrl = s.cbpath3.ToString();
            Image3.ImageUrl = s.cbpath4.ToString();
            Image4.ImageUrl = s.cbpath5.ToString();
            Image5.ImageUrl = s.cbpath6.ToString();
        }
        private void bind1()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");
            Image1.ImageUrl = s.cbpath2.ToString();
        }
        private void bind2()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");

            Image2.ImageUrl = s.cbpath3.ToString();

        }
        private void bind3()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");

            Image3.ImageUrl = s.cbpath4.ToString();

        }
        private void bind4()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");

            Image4.ImageUrl = s.cbpath5.ToString();

        }
        private void bind5()
        {
            cbshop s = cbshop.Find(" cbuserid = '" + AliApi.appUserId + "'");

            Image5.ImageUrl = s.cbpath6.ToString();
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload2.FileName.Substring(FileUpload2.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload2.HasFile)
            {
                FileUpload2.SaveAs(strFilePth);
                cbshop s = cbshop.findorcreate(AliApi.appUserId);
                s.cbpath2.Value = linkpth;
                s.Modify();
                bind1();
                MessageBox.Show(this.Page, "上传成功");
                return;
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            cbshop s = cbshop.findorcreate(AliApi.appUserId);
            s.cbpath2.Value = "";
            s.Modify();
            bind2();
            MessageBox.Show(this.Page, "操作完成");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload1.HasFile)
            {
                FileUpload1.SaveAs(strFilePth);
                cbshop s = cbshop.findorcreate(AliApi.appUserId);
                s.cbpath3.Value = linkpth;
                s.Modify();
                bind2();
                MessageBox.Show(this.Page, "上传成功");
                return;
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            cbshop s = cbshop.findorcreate(AliApi.appUserId);
            s.cbpath3.Value = "";
            s.Modify();
            bind2();
            MessageBox.Show(this.Page, "操作完成");
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload3.FileName.Substring(FileUpload3.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload3.HasFile)
            {
                FileUpload3.SaveAs(strFilePth);
                cbshop s = cbshop.findorcreate(AliApi.appUserId);
                s.cbpath4.Value = linkpth;
                s.Modify();
                bind3();
                MessageBox.Show(this.Page, "上传成功");
                return;
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            cbshop s = cbshop.findorcreate(AliApi.appUserId);
            s.cbpath3.Value = "";
            s.Modify();
            bind3();
            MessageBox.Show(this.Page, "操作完成");
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload4.FileName.Substring(FileUpload4.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload4.HasFile)
            {
                FileUpload4.SaveAs(strFilePth);
                cbshop s = cbshop.findorcreate(AliApi.appUserId);
                s.cbpath5.Value = linkpth;
                s.Modify();
                bind4();
                MessageBox.Show(this.Page, "上传成功");
                return;
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            cbshop s = cbshop.findorcreate(AliApi.appUserId);
            s.cbpath4.Value = "";
            s.Modify();
            bind4();
            MessageBox.Show(this.Page, "操作完成");
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            string strImg2 = FileUpload5.FileName.Substring(FileUpload5.FileName.LastIndexOf(".") + 1);
            string time2 = DateTime.Now.ToString("yyyyMMddhhmmss") + "." + strImg2;
            string strFilePth = Server.MapPath(@"~/file/") + time2;
            string linkpth = ResolveUrl(@"~/file/") + time2;
            if (FileUpload5.HasFile)
            {
                FileUpload5.SaveAs(strFilePth);
                cbshop s = cbshop.findorcreate(AliApi.appUserId);
                s.cbpath6.Value = linkpth;
                s.Modify();
                bind5();
                MessageBox.Show(this.Page, "上传成功");
                return;
            }
            MessageBox.Show(this.Page, "上传失败");
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            cbshop s = cbshop.findorcreate(AliApi.appUserId);
            s.cbpath5.Value = "";
            s.Modify();
            bind5();
            MessageBox.Show(this.Page, "操作完成");
        }
    }
}
